<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<link rel="stylesheet" href="../../../../../../guns-base-support/guns-sys/src/main/webapp/assets/common/libs/layui/css/layui.css" media="all">


	<body>

		<form class="layui-form" action="" id="frame">

			<div class="layui-form-item">
				<div class="layui-form-item" >
					<div id="addBtn">
						<input class="layui-btn" type="button" name="delete_col" id="delete_col" value="删除一行" />
						<input class="layui-btn" type="button" name="add_col" id="add_col" value="添加一行" />

					</div>
					<div class="layui-inline">
						<label class="layui-form-label">框架名字</label>
						<div class="layui-input-inline">
							<input type="text" name="sframeName" lay-verify="required" autocomplete="off" class="layui-input" value="">
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">组织</label>
						<div class="layui-input-inline">
							<input type="text" name="organization" lay-verify="required" autocomplete="off" class="layui-input">
						</div>
					</div>
				</div>
				<div id="sframe_item"  class="layui-input layui-table-edit">
					<div id="serial">
						<input type="text" contenteditable="false" />
					</div>
				</div>

				<div class="layui-input-block">
					<button id="submit" class="layui-btn" type="submit" lay-filter="demo1" lay-submit="">立即提交</button>
					<button class="layui-btn layui-btn-primary" type="reset">重置</button>
				</div>
			</div>

		</form>
		<script type="text/javascript" src="${ctxPath}/assets/common/libs/layui/layui.js?v=${constants.getReleaseVersion()}"></script>

		<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
		<script>
            var Feng = {
                ctxPath: "${ctxPath}",
                version: '${constants.getReleaseVersion()}'
            };
            layui.use(['jquery','layer', 'form', 'table', 'laydate',  'tree', 'util'], function () {
                var $=layui.jquery;
                var layer = layui.layer;
                var form = layui.form;
                var table = layui.table;
                var $ax = layui.ax;
                var laydate = layui.laydate;
                var tree = layui.tree;
                var util = layui.util;





                /**
                 * 系统管理--用户管理
                 */
                var MgrUser = {
                    tableId: "userTable",    //表格id
                    condition: {
                        name: "",
                        deptId: "",
                        timeLimit: ""
                    }
                };

				//时间范围
				laydate.render({
					elem: '#test9',
					type: 'time',
					range: true
				});

			//弹出一个页面层
                /**
                 * 弹出添加用户对话框
                 */
/*                MgrUser.openAddUser = function () {
                    layer.open({
						type:2,
                        area: ['600px', '360px'],
                        title: '添加日程项',
                        content: Feng.ctxPath + '/myScheduleFrame/addSframeItem',
                        tableId: MgrUser.tableId
                    });
                };*/

				 $('#sframe_item').on('click', function(){
                     layer.open({
                         type:2,
                         area: ['600px', '360px'],
                         title: '添加日程项',
                         content: Feng.ctxPath + '/myScheduleFrame/addSframeItem',
                         tableId: MgrUser.tableId
                     });
  });



				//自定义验证规则
				form.verify({
					title: function(value) {
						if(value.length < 5) {
							return '标题至少得5个字符啊';
						}
					},
					content: function(value) {
						layedit.sync(editIndex);
					}
				});

				//监听提交
				form.on('submit(demo1)', function(data) {
					layer.alert(JSON.stringify(data.field), {
						title: '最终的提交信息'
					})
					return false;
				});

/*				//表单取值
				layui.$('#LAY-component-form-getval').on('click', function() {
					var data = form.val('example');
					alert(JSON.stringify(data));
				});*/

				$(function() {
					//添加日程项
					$("#add_col").click(function() {
						$mtr = $("#amsTbody tr:last").clone();

						$mtr.each(function(i, e) {
							$(e).first("input").val("日程项");
						});
						$("#amsTbody tr:last").after($mtr);

/*
                        $('#sframe_item').on('click', function(){
                            layer.open({
                                type:2,
                                area: ['600px', '360px'],
                                title: '添加日程项',
                                content: Feng.ctxPath + '/myScheduleFrame/addSframeItem',
                                tableId: MgrUser.tableId
                            });
                        });*/



					});

					$("sframe_item_date").click(function() {
						laydate.render({
							elem: '#test9',
							type: 'time',
							range: true
						});
					});

					//点击删除一行
					$("#delete_col").click(function() {

						if($("#amsTbody tr").length <= 2) {
							return;
						}
						$("#amsTbody tr:last").remove();
					});



					//获取表单的值
					$("#submit").click(function () {
                        $.ajax({
                            url : '/myScheduleFrame/save', 　   <!-- url  :请求地址 -->
                            type : 'post',　　　　　　　　<!--type ：请求类型:post/get -->
                            data : $('#frame').serialize(),
                            dataType : 'json',                    <!--dataType:服务器返回的数据类型 text/xml/script/html/json/jsonp -->
                            success: function(data){　　　<!--回调函数 -->
                                console.log($('#frame').serialize());
                                console.log(data);

                            }

                        });


                    });

				});





			});
		</script>
	</body>

</html>